import Vue from "vue";
import Router from "vue-router";
import store from "@/store/index";

Vue.use(Router);

const router = new Router({
  routes: [
    {
      path: "/",
      redirect: "/xyfc"
    },
    {
      path: "/tbkt",
      name: "tbkt",
      component: () => import("@/components/tbkt/TBKTIndex")
    },
    {
      path: "/xyfc",
      name: "xyfc",
      component: () => import("@/components/xyfc/XYFCIndex")
    },
    {
      path: "/xyaq",
      name: "xyaq",
      component: () => import("@/components/xyaq/XYAQIndex")
    },
    {
      path: "/tbkt_wkt",
      name: "wkt",
      component: () => import("@/components/tbkt/wkt")
    },
    {
      path: "/tbkt_wkt/wkt_dt/:id/:name",
      name: "wkt_dt",
      component: () => import("@/components/tbkt/wkt_dt")
    },
    {
      path: "/tbkt_xgkk",
      name: "xgkk",
      component: () => import("@/components/tbkt/Xgkk")
    },
    {
      path: "/tbkt_hskt",
      name: "tbkt_hskt",
      component: () => import("@/components/tbkt/hskt")
    },
    {
      path: "/hskt/zsd/:folderCode",
      component: () => import("@/components/tbkt/hskt-zsd")
    },
    {
      path: "/tbkt/msgkk",
      component: () => import("@/components/tbkt/msgkk")
    },
    {
      path: "/tbkt/msgkk/msjs",
      component: () => import("@/components/tbkt/msgkk-msjs.vue")
    },
    {
      path: "/tbkt/msgkk/list/:folderCode/:name",
      component: () => import("@/components/tbkt/msgkk-list-in")
    },
    {
      path: "/tbkt/msgkk_lmsj",
      component: () => import("@/components/tbkt/msgkk-lmjs")
    },
    {
      path: "/tbkt/msgkk_msjs_detail/:fodderid",
      component: () => import("@/components/tbkt/msgkk-msjs-detail")
    },
    {
      path: "/xyfc/xyxxs/:index",
      component: () => import("@/components/xyfc/xyxxs")
    },
    {
      path: "/xyfc/voter/:vindex",
      component: () => import("@/components/xyfc/voter-index")
    },
    {
      path: "/xyfc/voter_detail/:voteId/:index",
      component: () => import("@/components/xyfc/voter-detail")
    },
    {
      path: "/xyfc/voter_all",
      component: () => import("@/components/xyfc/voter-all")
    },
    {
      path: "/xyfc/voter_intro/:materialId",
      name: 'xyfc-voter_intro',
      component: () => import("@/components/xyfc/voter-intro")
    },
    {
      path: "/xyfc/xyzb",
      name: 'xyfc-xyzb',
      component: () => import("@/components/xyfc/xyzb")
    },
    {
      path: "/person",
      name: 'person',
      component: () => import("@/components/personal/personal")
    },
    {
      path: "/personal",
      name: 'personal',
      component: () => import("@/components/personal/personalIndex")
    },
    {
      path: "/noticeWork",
      name: "noticeWork",
      component: () => import("@/components/personal/noticeWork")
    },
    {
      path: "/scorAnalysis",
      name: "scorAnalysis",
      component: () => import("@/components/personal/scorAnalysis")
    },
    {
      path: "/dekt",
      name: 'dekt',
      component: () => import("@/components/dekt/dekt")
    },
    {
      path: "/select",
      name: 'select',
      component: () => import("@/components/xyfc/select-school")
    },
    {
      path: "/yckt",
      name: "yckt",
      component: () => import("@/components/yckt/yckt")
    },

    // test url
    {
      path: "/testchart",
      name: "testchart",
      component: () => import("@/components/testchart")
    },
    {
      path: "/construction",
      name: "construction",
      component: () => import("@/components/construction")
    },
    {
      path: "/modifyPhone",
      name: "modifyPhone",
      component: () => import("@/components/personal/modifyPhone")
    }
  ]
});

router.beforeEach((to, from, next) => {
  // console.log(to);
  // 初始化返回函数和关闭视频
  if (Object.keys(store.state.bridge).length !== 0) {
    store.state.bridge.whenKeyBack = null;
  }
  // 初始化hs
  store.commit("initHs");
  next();
});

router.afterEach((to, from) => {
  // console.log(to);
  document.querySelector('#apploading').style.display = 'none'
})

export default router;
